import { createVNode, render } from 'vue'
import XtxConfirm from './xtx-confirm.vue'
const vNodeDiv = createVNode('div', { class: 'xtx-message-container' })
render(vNodeDiv, document.body)
const div = vNodeDiv.el
const confirm = ({ title, text }) => {
  return new Promise((resolve, reject) => {
    const confirmCallback = () => {
      render(null, div)
      resolve('删除')
    }
    const cancelCallback = () => {
      render(null, div)
      reject(new Error('点击取消'))
    }
    const vNode = createVNode(XtxConfirm, { title, text, confirmCallback, cancelCallback })
    render(vNode, div)
  })
}
export default confirm
